package Demo1;

import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: adol book
 * Date: 2022-05-03
 * Time: 16:25
 */

class Card{
    public void Shape(){
        System.out.print("形状");
    }
}
class G extends Card{

    @Override
    public void Shape() {
        System.out.print("♠");
    }
}
class F extends Card{

    @Override
    public void Shape() {
        System.out.print("♥");
    }
}
class Y extends Card{

    @Override
    public void Shape() {
        System.out.print("♣");
    }
}
class H extends Card{
    @Override
    public void Shape() {
        System.out.print("♦");
    }
}
public class TestDemo2 {
    public static void doShape(Card card){ //定义一个方法，传父类的对象
        card.Shape();
    }
    public static void DOSjape(){
        G g = new G();
        F f = new F();
        Y y = new Y();
        H h = new H();
        Card[] cards = {g,f,y,y,h,f,h,g}; //数组打印想要的顺序
        for (Card card:cards) {
            card.Shape();
        }
    }
    public static void main(String[] args) {
        doShape(new F());
        doShape(new G());
        doShape(new H());
        doShape(new Y());
        DOSjape();
    }
}
